<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ include file="/commons/global.jsp"%>

<html>
<head>
    <title>${sys_name}</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <%@ include file="/commons/head.jsp"%>

</head>

  <body>
    <div class="x-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>登录名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userCode" name="userCode" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>将会成为您唯一的登入名
              </div>
          </div>
          <div class="layui-form-item">
              <label for="userName" class="layui-form-label">
                  <span class="x-red">*</span>姓名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userName" name="userName" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>您的姓名
              </div>
          </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="L_pass" name="passwd" required="" lay-verify="passwd"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="userdept" class="layui-form-label">
                    <span class="x-red">*</span>所在单位
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="userdept" name="userdept" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>

          <div class="layui-form-item">
              <label class="layui-form-label"><span class="x-red">*</span>角色</label>

              <div class="layui-input-block">
                  <input type="radio" name="qxclass" value="1" title="管理员" >
                  <input type="radio" name="qxclass" value="2" title="yingZHANG">
                  <input type="radio" name="qxclass" value="3" title="操作员" checked="">
              </div>
          </div>
            <div class="layui-form-item">
            <label class="layui-form-label">选择专业组</label>
            <div class="layui-input-inline">
                <select name="zyzId"  lay-search="">
                    <option value="">直接选择或搜索选择</option>
                    <option value="1">计算机</option>
                    <option value="2">经济</option>
                    <option value="3">文学</option>
                    <option value="4">element</option>


                </select>
            </div>
            </div>

          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" id="save" lay-submit="">
                  增加
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          //自定义验证规则
          form.verify({
            nikename: function(value){
              if(value.length < 5){
                return '昵称至少得5个字符啊';
              }
            }
            ,passwd: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
          });

          //监听提交
          form.on('submit(add)', function(data){
                      //发异步，把数据提交给php
             $.post('<%=basePath%>user/save',data.field,function(res){
                  if(res.flag){
                       layer.msg(res.msg, {time: 2000});
                       layer.alert("增加成功", {icon: 6},function () {
                          // 获得frame索引
                          var index = parent.layer.getFrameIndex(window.name);
                           parent.location.replace( parent.location.href);  //刷新
                           console.log(parent.location.href);
                          //关闭当前frame
                           parent.layer.close(index);

                           return false;

                      });
                }else{
                      layer.msg(res.msg, {time: 2000});
                      return false;
                    //  x_admin_close();
                  }
              },'json');
            return false ;
          });

        });
    </script>

  </body>

</html>